package com.zhiche.lisa.lspm.dao.mapper.fleet;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.zhiche.lisa.lspm.dao.model.fleet.Fleet;
import com.zhiche.lisa.lspm.vo.fleet.FleetCarId;
import com.zhiche.lisa.lspm.vo.fleet.FleetLineVO;
import com.zhiche.lisa.lspm.vo.fleet.FleetManagementListVO;
import com.zhiche.lisa.lspm.vo.fleet.FleetVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 车队 Mapper 接口
 * </p>
 *
 * @author qichao
 * @since 2018-07-18
 */
public interface FleetMapper extends BaseMapper<Fleet> {
    /**
     * 查询绑定车队信息
     */
    List<FleetLineVO> queryFleetBindPage(Page<FleetLineVO> page, @Param("ew") EntityWrapper<FleetLineVO> ew);

    List<FleetLineVO> queryFleetBindList(@Param("ew") Wrapper<FleetLineVO> ew);

    List<Fleet> selectListNoTenant(@Param("ew") Wrapper<Fleet> ew);

    Fleet selectNoTenant(@Param("ew")  Wrapper<Fleet> ew);

    Fleet selectByIdNoTenant(@Param("fleetId") Long fleetId);

    List<FleetManagementListVO> FleetManagementList(Page<FleetManagementListVO> page, @Param("ew") Wrapper<FleetManagementListVO> ew);

    /**
     * 根据牵引车ID或者挂车ID查询车队信息
     * 老查法未用resource_type进行区分可能查出多条
     * @param carrierId 牵引车ID
     * @param trailerId 挂车ID
     * @return FleetCarId
     */
    List<FleetCarId> selectOldFleetByCarrierIdOrTrailerIdNoTenant(@Param("carrierId") Long carrierId, @Param("trailerId") Long trailerId);

    /**
     * 根据牵引车ID或者挂车ID查询车队信息
     * 新查法使用resource_type进行区分
     * @param carrierId 牵引车ID
     * @param trailerId 挂车ID
     * @return FleetCarId
     */
    FleetCarId selectNewFleetByCarrierIdOrTrailerIdNoTenant(@Param("carrierId") Long carrierId, @Param("trailerId") Long trailerId);

    /**
     * 根据车队ID查询车队信息及其银行信息
     * @param ew
     * @return Fleet
     */
    List<Fleet> selectFleetByIds(@Param("ew") Wrapper<Fleet> ew);

    /**
     *  根据资源ID和类型查询车队信息
     * @param id 资源ID
     * @param type 资源类型
     * @return Fleet
     */
    Fleet selectOneByResourceIdAndType(@Param("type")String type,@Param("id")Long id);

    List<FleetLineVO> queryFleetBasicNoTenant(@Param("ew") Wrapper<FleetLineVO> ew);

    /**
     * 根据承运商手机获取公司车队列表
     * @param mobile
     * @return
     */
    List<Fleet> selectFleetByLspMobile(String mobile);

    List<FleetVo> getFleetList(@Param("page")Page<Map<String, Objects>> page, @Param("ew")EntityWrapper<Fleet> ew);
}
